#include "StdAfx.h"
#include "TaskManager.h"
#include <assert.h>
#include <algorithm>

TaskManager::TaskManager(void)
{
}


TaskManager::~TaskManager(void)
{
}

void TaskManager::add( const wstring& ip )
{
	cs.lock();
	if (has_ip(ip))
	{
		cs.unlock();
		return;
	}
	ips.push_back(ip);
	cs.unlock();
}

bool TaskManager::has_ip( const wstring& ip )
{
	cs.lock();
	bool ret = (ips.end() != find(ips.begin(), ips.end(), ip));
	cs.unlock();
	return ret;
}

void TaskManager::remove( const wstring& ip )
{
	cs.lock();
	ips.erase(std::remove(ips.begin(), ips.end(), ip));
	cs.unlock();
}
